NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name [Fit AF] Shrink List Widths 3 // @namespace FitAF // @include https://trello.com/* // @require http://code.jquery.com/jquery-3.4.1.min.js // @resource customCSS https://code.jquery.com/ui/1.12.1/themes/ui-lightness/jquery-ui.css // @require https://code.jquery.com/ui/1.12.0/jquery-ui.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/mathjs/10.0.0/math.js // @grant GM_addStyle // @grant GM_getResourceText // @updateURL https://openuserjs.org/meta/macheteYeti/[Fit_AF]_Shrink_List_Widths.user.js // @license MIT // @author macheteYeti // @description Reassigns widths on Trello lists to accommodate more visible task lists simultaneously // @version 5 // ==/UserScript== var newCSS = GM_getResourceText ("customCSS"); GM_addStyle (newCSS); GM_addStyle( ` #board{display:flex,flex-direction:column,align-content:space between,flex-flow:row wrap} ` ); var Arrive=function(e,t,n){"use strict";function r(e,t,n){l.addMethod(t,n,e.unbindEvent),l.addMethod(t,n,e.unbindEventWithSelectorOrCallback),l.addMethod(t,n,e.unbindEventWithSelectorAndCallback)}function i(e){e.arrive=f.bindEvent,r(f,e,"unbindArrive"),e.leave=d.bindEvent,r(d,e,"unbindLeave")}if(e.MutationObserver&&"undefined"!=typeof HTMLElement){var o=0,l=function(){var t=HTMLElement.prototype.matches||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector;return{matchesSelector:function(e,n){return e instanceof HTMLElement&&t.call(e,n)},addMethod:function(e,t,r){var i=e[t];e[t]=function(){return r.length==arguments.length?r.apply(this,arguments):"function"==typeof i?i.apply(this,arguments):n}},callCallbacks:function(e,t){t&&t.options.onceOnly&&1==t.firedElems.length&&(e=[e[0]]);for(var n,r=0;n=e[r];r++)n&&n.callback&&n.callback.call(n.elem,n.elem);t&&t.options.onceOnly&&1==t.firedElems.length&&t.me.unbindEventWithSelectorAndCallback.call(t.target,t.selector,t.callback)},checkChildNodesRecursively:function(e,t,n,r){for(var i,o=0;i=e[o];o++)n(i,t,r)&&r.push({callback:t.callback,elem:i}),i.childNodes.length>0&&l.checkChildNodesRecursively(i.childNodes,t,n,r)},mergeArrays:function(e,t){var n,r={};for(n in e)e.hasOwnProperty(n)&&(r[n]=e[n]);for(n in t)t.hasOwnProperty(n)&&(r[n]=t[n]);return r},toElementsArray:function(t){return n===t||"number"==typeof t.length&&t!==e||(t=[t]),t}}}(),c=function(){var e=function(){this._eventsBucket=[],this._beforeAdding=null,this._beforeRemoving=null};return e.prototype.addEvent=function(e,t,n,r){var i={target:e,selector:t,options:n,callback:r,firedElems:[]};return this._beforeAdding&&this._beforeAdding(i),this._eventsBucket.push(i),i},e.prototype.removeEvent=function(e){for(var t,n=this._eventsBucket.length-1;t=this._eventsBucket[n];n--)if(e(t)){this._beforeRemoving&&this._beforeRemoving(t);var r=this._eventsBucket.splice(n,1);r&&r.length&&(r[0].callback=null)}},e.prototype.beforeAdding=function(e){this._beforeAdding=e},e.prototype.beforeRemoving=function(e){this._beforeRemoving=e},e}(),a=function(t,r){var i=new c,o=this,a={fireOnAttributesModification:!1};return i.beforeAdding(function(n){var i,l=n.target;(l===e.document||l===e)&&(l=document.getElementsByTagName("html")[0]),i=new MutationObserver(function(e){r.call(this,e,n)});var c=t(n.options);i.observe(l,c),n.observer=i,n.me=o}),i.beforeRemoving(function(e){e.observer.disconnect()}),this.bindEvent=function(e,t,n){t=l.mergeArrays(a,t);for(var r=l.toElementsArray(this),o=0;o<r.length;o++)i.addEvent(r[o],e,t,n)},this.unbindEvent=function(){var e=l.toElementsArray(this);i.removeEvent(function(t){for(var r=0;r<e.length;r++)if(this===n||t.target===e[r])return!0;return!1})},this.unbindEventWithSelectorOrCallback=function(e){var t,r=l.toElementsArray(this),o=e;t="function"==typeof e?function(e){for(var t=0;t<r.length;t++)if((this===n||e.target===r[t])&&e.callback===o)return!0;return!1}:function(t){for(var i=0;i<r.length;i++)if((this===n||t.target===r[i])&&t.selector===e)return!0;return!1},i.removeEvent(t)},this.unbindEventWithSelectorAndCallback=function(e,t){var r=l.toElementsArray(this);i.removeEvent(function(i){for(var o=0;o<r.length;o++)if((this===n||i.target===r[o])&&i.selector===e&&i.callback===t)return!0;return!1})},this},s=function(){function e(e){var t={attributes:!1,childList:!0,subtree:!0};return e.fireOnAttributesModification&&(t.attributes=!0),t}function t(e,t){e.forEach(function(e){var n=e.addedNodes,i=e.target,o=[];null!==n&&n.length>0?l.checkChildNodesRecursively(n,t,r,o):"attributes"===e.type&&r(i,t,o)&&o.push({callback:t.callback,elem:i}),l.callCallbacks(o,t)})}function r(e,t){return l.matchesSelector(e,t.selector)&&(e._id===n&&(e._id=o++),-1==t.firedElems.indexOf(e._id))?(t.firedElems.push(e._id),!0):!1}var i={fireOnAttributesModification:!1,onceOnly:!1,existing:!1};f=new a(e,t);var c=f.bindEvent;return f.bindEvent=function(e,t,r){n===r?(r=t,t=i):t=l.mergeArrays(i,t);var o=l.toElementsArray(this);if(t.existing){for(var a=[],s=0;s<o.length;s++)for(var u=o[s].querySelectorAll(e),f=0;f<u.length;f++)a.push({callback:r,elem:u[f]});if(t.onceOnly&&a.length)return r.call(a[0].elem,a[0].elem);setTimeout(l.callCallbacks,1,a)}c.call(this,e,t,r)},f},u=function(){function e(){var e={childList:!0,subtree:!0};return e}function t(e,t){e.forEach(function(e){var n=e.removedNodes,i=[];null!==n&&n.length>0&&l.checkChildNodesRecursively(n,t,r,i),l.callCallbacks(i,t)})}function r(e,t){return l.matchesSelector(e,t.selector)}var i={};d=new a(e,t);var o=d.bindEvent;return d.bindEvent=function(e,t,r){n===r?(r=t,t=i):t=l.mergeArrays(i,t),o.call(this,e,t,r)},d},f=new s,d=new u;t&&i(t.fn),i(HTMLElement.prototype),i(NodeList.prototype),i(HTMLCollection.prototype),i(HTMLDocument.prototype),i(Window.prototype);var h={};return r(f,h,"unbindAllArrive"),r(d,h,"unbindAllLeave"),h}}(window,"undefined"==typeof jQuery?null:jQuery,void 0); GM_addStyle( ` #hider{background:#fff;width:2em;line-height:2em;vertical-align:middle;text-align:center;border-bottom-right-radius:1em;border-top-right-radius:1em;position:absolute;z-index:1001;top:calc(50% - 2em);left:-20px;font-weight:bold;font-size:2em;font-family:monospace;cursor:pointer} #hider.open{background-color:#ccc;border-top-left-radius:1em;border-bottom-left-radius:1em;border-top-right-radius:0;border-bottom-right-radius:0} #controlHide{display:block;width:420px;background:rgba(0,0,0,0.7);padding:1em;border-radius:1em;top:calc(50%-4em);position:absolute;left:-450px;z-index:1000} #controlHide label{margin:0;font-weight:normal;font-family:sans-serif;color:#fff} #listsList,.multiCheck{display:none} .multiCheck{position:absolute;width:20px;height:20px;z-index:9999;cursor:pointer} .multiCheck input{width:20px;height:20px;cursor:pointer} #listsList li{cursor:pointer} .scaling{margin-top:10px} .scaling input{width:125px;float:left;margin-right:10px;height:32px} .scaling button:hover{background-color:#000;color:#fff} ` ); $(document).ready(function(){ function reduce(numerator,denominator){ var gcd = function gcd(a,b){ return b ? gcd(b, a%b) : a; }; gcd = gcd(numerator,denominator); return [numerator/gcd, denominator/gcd]; } kit=0; temp=0; team=0; $(document).arrive('.js-board-editing-target',function(){ /* if(kit){ console.log('prompting'); team=prompt("Select a Team\n\n0 = Both\n1 = Prep 1\n2 = Prep 2"); } */ }); /* $(document).on('click','.list-card *',function(e){ if($('#multiMove').hasClass('selecting')){ console.log('clicking card, preventing default'); e.preventDefault(); e.stopPropagation(); e.stopImmediatePropagation(); } }); */ /* $(document).arrive('.board-header-btns.mod-right',function(){ if($('#multiMove').length==0){ $('.board-header-btns.mod-right').prepend($('<span class="js-butler-header-btns board-header-btn-react-container" id="multiMove"><div class="js-react-root"><button class="_3K09J3xqj8n-uQ _3TTqkG5muwOzqZ ZOUktZwsING7-0 _1Tu9wiuW4Te8Rx" type="button" tabindex="0"><span>Multi-Move<span class="ATjiijuQ4KooJb"></span></span></button></div><ul id="listsList"></ul></span>')); } }); */ /* $(document).on('click','#multiMove',function(){ if($(this).hasClass('selecting')){ $('#listsList').slideDown(); } else{ $('.multiCheck').fadeIn(); } $(this).toggleClass('selecting'); }); */ /* $(document).on('click','#listsList li',function(){ var newList=$(this).text(); $('.multiCheck input:checked').each(function(){ $(this).parents('.list-card-details').find('.list-card-title.js-card-name').trigger('click'); $('.button-link.js-move-card').trigger('click'); $('.js-select-list').val(newList); $('nch-button.nch-button--primary.wide.js-submit').trigger('click'); }); $('.multiCheck input').prop('checked','false'); $('.multiCheck').fadeOut(); }); $(document).arrive('.list-card-title.js-card-name',function(){ $(this).prepend("<span class='multiCheck'><input type='checkbox'></span>"); }); $(document).on('click','.multiCheck,.multiCheck input',function(e){ console.log('selecting card'); e.stopPropagation(); e.stopImmediatePropagation(); e.preventDefault(); return false; }); */ vis=0; $(document).arrive(".bi0h3HALKXjfDq", function(){ if(document.title.indexOf(' Kitchen Tasks')>-1)kit=1; else if(document.title.indexOf("Tasks Template")>-1)kit=1; // if(kit||temp){ /* if(team>0)height="100%"; else */ if($(this).find('.KLvU2mDGTQrsWG').text().indexOf(' ')==-1)height="28%"; else height="65%"; /* console.log("checking "+$(this).find('.KLvU2mDGTQrsWG').text()+" "+$(this).find('.KLvU2mDGTQrsWG').text().slice(-1)+" against "+team); if(team>0&&$(this).find('.KLvU2mDGTQrsWG').text().slice(-1)!=team.toString()&&$(this).find('.KLvU2mDGTQrsWG').text().slice(-1)!="0"){ $(this).hide(); } else{ */ $(this)/* .css('width','10%') */.css('height',height); $(this).find('.list-cards').css('max-height',height); vis++; // console.log('setting list name to '+$(this).find('.KLvU2mDGTQrsWG').text().slice(0,-2)); // $(this).find('.KLvU2mDGTQrsWG').text($(this).find('.KLvU2mDGTQrsWG').text().slice(0,-2)); // $(this).find('.KLvU2mDGTQrsWG').next('textarea').text($(this).find('.KLvU2mDGTQrsWG').text().slice(0,-2)); // console.log($(this).find('.KLvU2mDGTQrsWG').text()+" "+$(this).find('.KLvU2mDGTQrsWG').text().indexOf('Done')); /* if(team==1&&$(this).find('.KLvU2mDGTQrsWG').text().indexOf('Done')>-1){ console.log('moving done'); $(this).insertBefore($('.list-wrapper').first()); } */ // } if($(this).hasClass('js-add-list'))$(this).css('position','absolute').css('right','0').css('bottom','0').css('height','10%'); // } console.log(kit); if(kit)width=((100/vis*2)-1)+"%"; else width=(100/vis)+"%"; console.log(vis+" "+width); $(".bi0h3HALKXjfDq").css('width',width); $(".bi0h3HALKXjfDq .Sb_QqNKeadm2oq").css('width',"100%"); $('#listsList').append($('<li>'+$(this).find('.KLvU2mDGTQrsWG').text()+'</li>')); }); $(document).on('click','#hider',function(){ if(!$('#controlHide').hasClass('filled')){ $('.bi0h3HALKXjfDq:not(.js-add-list)').each(function(i){ $(this).attr('id','l'+i); $('#controlHide').append("<li><label><input type='checkbox' checked name='l"+i+"' class='hider'>"+$(this).find('.KLvU2mDGTQrsWG').text()+"</label></li>"); }); $('#controlHide').addClass('filled'); $('#controlHide').css('top',($(document).outerHeight()-$('#controlHide').outerWidth())/5+'px'); } if($('#controlHide').css('left')=='-450px'){ $('#controlHide').animate({'left':0}); $('#hider').addClass('open').text('<'); $('#hider').animate({'left':'392px'}); } else{ $('#controlHide').animate({'left':"-450px"}); $('#hider').removeClass('open').text('>').animate({'left':'-20px'}); } }); $(document).on({ mouseleave:function(){ if(!$(this).hasClass('open'))$(this).animate({'left':'-20px'},500); }, mouseenter:function(){ if(!$(this).hasClass('open'))$(this).animate({'left':'0'},500); } },'#hider'); $(document).arrive('#board',function(){ if(document.title.indexOf(' Kitchen Tasks')>-1)kit=1; else if(document.title.indexOf("Tasks Template")>-1)kit=1; if(kit)$(this).css({"display":"flex","flex-direction":"column","align-content":"space between","flex-flow":"row wrap"}); $(this).prepend('<div id="hider">></div><ul id="controlHide"></ul>'); }); $(document).arrive(".js-add-another-card",function(){ if(kit)$(this).text('Add card'); }); $(document).arrive(".js-add-a-card",function(){ if(kit)$(this).text('Add card'); }); $(document).arrive('.badges',function(){ if(kit)$(this).hide(); }); $(document).arrive('.js-card-templates-button',function(){ if(kit)$(this).hide(); }); // $(document).arrive('.board-header',function(){ if(kit)$(this).hide(); }); $(document).arrive('#header',function(){ if(kit)$(this).parent().parent().hide(); }); $(document).arrive('.card-detail-window',function(){ var timing=0; var id=""; $(this).find('.current.markeddown').find('p').each(function(){ // $(this).text($(this).html().replaceAll('Â',"")); // console.log($(this).text()); if($(this).text().indexOf('Roast')>-1||$(this).text().indexOf('Boil')>-1)timing=1; if($(this).text().indexOf('mi:')>-1){ id=$(this).text().split('mi:')[1]; } // if($(this).text().indexOf('{')>-1)id=$(this).text().split('{')[1]; // else console.log("did not find roast in "+$(this).text()); }); if(timing){ console.log('found timable task'); $('.window-header.js-card-detail-header').append('<div class="timer"><input style="width:100px;float:left;margin-right:10px;height:32px" placeholder="# of minutes"><button data-ingred="'+id+'">Start Timer</button></div><br>'); } $('.window-header.js-card-detail-header').append('<div class="scaling"><input placeholder="Scaling Factor"><button>Scale</button></div>'); }); function scaleVals(scaleWay,x,scale){ // console.log(scaleWay); // console.log(x); build=""; if(isNaN(x)){ if(x.indexOf("/")>-1&&x.indexOf("</")==-1){ if(scaleWay=='up'){ console.log(x); build+=math.multiply(math.fraction(x),scale)+" "; } else{ console.log(x); build+=math.divide(math.fraction(x),scale)+" "; } } else{ if(x.substr(0,1)=='x'&&!isNaN(x.substr(1,1))){ var y=x.replace('x',''); if(scaleWay=='up')build+="x"+(y*scale)+" "; else build+="x"+(y/scale)+" "; } else build+=x+" "; } } else{ if(scaleWay=='up')build+=(x*scale)+" "; else build+=(x/scale)+" "; } // console.log(build); return build; } $(document).on('click','.scaling button',function(){ var replace=[]; var scale=$('.scaling input').val(); var scaleWay='up'; if($(this).text()=='Unscale')scaleWay='down'; $.each($('.current.markeddown').html().replaceAll('<p dir="auto">','<p dir="auto"> ').split("\n"),function(i,v){ build=""; if(v.indexOf("<br>")>-1){ $.each(v.split("<br>"),function(j,w){ $.each(w.split(" "),function(k,x){ build+=scaleVals(scaleWay,x.replace("<li>","").replace("</li>",""),scale); }); build+="<br>"; }); build.trim("<br>"); } else $.each(v.split(" "),function(k,x){/* console.log(x); */build+=scaleVals(scaleWay,x.replace("<li>","").replace("</li>",""),scale);}); replace.push(build); }); repVal=replace.join("\n").replaceAll(" 0","").replaceAll('<p dir="auto"> ','<p dir="auto">').replaceAll('</p> <br>','</p>').replaceAll('</p><br>','</p>'); console.log(repVal); $('.current.markdown').html(repVal); if(scaleWay=='up'){ $('.u-inline-block').html("Description <span style='font-variant:small-caps'>Scaled x"+scale+"</span>"); $('.scaling button').text('Unscale'); } else{ $('.u-inline-block').html("Description"); $('.scaling button').text('Scale'); $('.scaling input').empty().val(''); } }); $(document).on('click','.timer button',function(){ var ingred=$(this).attr('data-ingred'); var duration=$(this).prev().val(); var t=$(this); var i=$(this).prev(); t.addClass('ui-state-highlight'); $.ajax({ type:'GET', crossDomain:true, cache:false, dataType:'json', url:"https://fitaf570.com/setTrello.php", data:{type:'timer',ingred:ingred,duration:duration},done:function(d){ // d=$.parseJSON(d); console.log(d); /* if(d.success==1)t.removeClass('ui-state-highlight').effect('highlight',{},1000); else t.removeClass('ui-state-highlight').addClass('ui-state-error'); */ if(d.success=1){ i.val(''); i.removeAttr('value'); } else t.text('Error!'); } }); }); $(document).on('change','#controlHide li input',function(){ $('#'+$(this).attr('name')).fadeToggle(); }); });